package functional;

import java.util.Arrays;
import java.util.List;
import java.util.function.BiConsumer;

/**
 * Created by yzy on 2021-03-17 17:51
 */
public class FunctionalStrategy {

    public static void main(String[] args) {
        List<Integer> list1 = Arrays.asList(new Integer[]{1,2,3,4,5});
        List<Integer> list2 = Arrays.asList(new Integer[]{6,7,8,9,10});
        int strategy = 1;
        BiConsumer<Integer, Integer> biConsumer;
        if(0 == strategy){
            biConsumer = FunctionalStrategy::exe1;
        }else if(1 == strategy){
            biConsumer = FunctionalStrategy::exe2;
        }else{
            biConsumer = FunctionalStrategy::exe3;
        }

        for(int i=0; i<list1.size(); i++){
            biConsumer.accept(list1.get(i), list2.get(i));
        }

    }

    private static void exe1(Integer a, Integer b){
        System.out.println("exe1..."+a + "-"+b);
    }

    private static void exe2(Integer a, Integer b){
        System.out.println("exe2..."+a + "-"+b);
    }

    private static void exe3(Integer a, Integer b){
        System.out.println("exe3..."+a + "-"+b);
    }
}
